博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
thinphp 自定义标签,非常方便在模板读取数据。
阅读量:6952 次
发布时间:2019-06-27

本文共 907 字,大约阅读时间需要 3 分钟。

hot3.png

thinphp 自定义标签的路径和标签类名如下:

thinphp自定义标签源码如下:

array('attr' => 'type,order,limit,where','close' => 1), ); public function _list($attr,$content) { $type = $attr['type']; //要查询的数据表 $order = $attr['order']; //排序 $limit = $attr['limit']; //多少条数据 $where = $attr['where']; //查询条件 $str = '
where("' . $where . '")->order("' . $order . '")->limit(' . $limit . ')->select();'; $str .= 'foreach ($result as $indextab):'; $str .= '?>'; $str .= $content; $str .= '
'; return $str; }}?>

thinkphp自定义标签在模板的使用方法与foreach标签和volist标签一样简单,且能套用使用。

注意:where 条件如果是字符串要有单引号如 where=”test = ‘test'”

例如:

  • {$indextab[create_time|date="y-m-d",###]}{$indextab[title]}
  • 还要去thinkphp下面的配置文件添加额外标签
    D:\wamp\wamp\www\caigou150613\ThinkPHP\Conf\convention.php
     ‘TAGLIB_PRE_LOAD’       =>  ‘Widgettab,Indextab’,   // 需要额外加载的标签库(须指定标签库名称),多个以逗号分隔 

    转载请注明: »

    转载于:https://my.oschina.net/guodingding/blog/528479

    你可能感兴趣的文章
    js 数组排序
    查看>>
    android笔记--处理started service的多次启动请求(转)
    查看>>
    UE4 学习笔记1 变量的初始化
    查看>>
    基本子类设计
    查看>>
    编码和解码
    查看>>
    UML 依赖 泛化 关联关系的区别
    查看>>
    ajaxSubmit与ajaxFileUpload的空值
    查看>>
    android 拨打电话与发送短信
    查看>>
    Spring学习(4)IOC容器配置bean:定义与实例化
    查看>>
    DOS查看端口占用及杀掉进程命令
    查看>>
    animate动画解析
    查看>>
    Curling 2.0 (poj 3009 dfs)
    查看>>
    SQL Server数据库存在判断语句及系统表简介
    查看>>
    如何查找完全二叉树最后一层的最右边的结点
    查看>>
    Cocos2d-x学习之---自定义图标(带触摸事件)
    查看>>
    Tip:部署sharepoint2013SP1指定SQL数据库时的小细节
    查看>>
    java设计模式演示样例
    查看>>
    MemCache分布式缓存的一个bug
    查看>>
    R语言屏幕输出
    查看>>
    创建与删除索引
    查看>>